import 'package:flutter/material.dart';
import 'package:surfaceim/common/values/values.dart';
import 'package:flutter_interactional_widget/flutter_interactional_widget.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

import 'index.dart';

class WelcomePage extends GetView<WelcomeController> {
  /// 页头标题
  Widget _buildPageHeadTitle() {
    return Container(
      margin: EdgeInsets.only(top: (60 + 44.0).h), // 顶部系统栏 44px
      child: Text(
        "Warning",
        textAlign: TextAlign.center,
        style: TextStyle(
          color: AppColors.primaryText,
          fontFamily: "Montserrat",
          fontWeight: FontWeight.w600,
          fontSize: 24.sp,
          height: 1,
        ),
      ),
    );
  }

  /// 页头说明
  Widget _buildPageHeaderDetail() {
    return Container(
      width: 242.w,
      height: 70.h,
      margin: EdgeInsets.only(top: 14.h),
      child: Text(
        "Execution failed for task ':app:mergeDexDebug'.",
        textAlign: TextAlign.center,
        style: TextStyle(
          color: AppColors.primaryText,
          fontFamily: "Avenir",
          fontWeight: FontWeight.normal,
          fontSize: 16.sp,
          height: 1.3,
        ),
      ),
    );
  }

  /// 开始按钮
  Widget _buildStartButton(BuildContext context) {
    return Container(
      width: 345.w,
      height: 88.h,
      margin: EdgeInsets.only(bottom: 40.h),
      child: TextButton(
        style: ButtonStyle(
          textStyle: MaterialStateProperty.all(TextStyle(
            fontSize: 16.sp,
          )),
          foregroundColor: MaterialStateProperty.resolveWith(
            (states) {
              if (states.contains(MaterialState.focused) &&
                  !states.contains(MaterialState.pressed)) {
                return Colors.blue;
              } else if (states.contains(MaterialState.pressed)) {
                return Colors.deepPurple;
              }
              return AppColors.primaryElementText;
            },
          ),
          backgroundColor: MaterialStateProperty.resolveWith((states) {
            // if (states.contains(MaterialState.pressed)) {
            //   return Colors.blue[200];
            // }
            return AppColors.primaryElement;
          }),
          shape: MaterialStateProperty.all(RoundedRectangleBorder(
            borderRadius: Radii.k6pxRadius,
          )),
        ),
        child: Text(
          "Get started",
          style: TextStyle(fontSize: 35.sp),
        ),
        onPressed: controller.handleNavSignIn,
      ),
    );
  }

  Widget banner(context) {
    return InteractionalWidget(
      width: Get.width,
      height: Get.height,
      maxAngleY: 30,
      maxAngleX: 40,
      middleScale: 1, // 中景层缩放比
      foregroundScale: 1.1, // 前景层的缩放比
      backgroundScale: 1.1, // 	背景层缩放比

      ///
      backgroundWidget: Container(
        width: Get.width,
        height: Get.height,
        child: Image.network(
          'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fc-ssl.duitang.com%2Fuploads%2Fitem%2F201910%2F08%2F20191008115212_bdrec.thumb.700_0.jpg&refer=http%3A%2F%2Fc-ssl.duitang.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1638545800&t=9b2ef5aa629e5e18693e24a5fdecb836',
          fit: BoxFit.cover,
          scale: 3.0,
        ),
      ),

      ///
      middleWidget: Container(
        width: Get.width,
        height: Get.height,
        child: Column(
          children: [
            _buildPageHeadTitle(),
            _buildPageHeaderDetail(),
            Spacer(),
            _buildStartButton(context),
          ],
        ),
      ),

      ///
      foregroundWidget: Container(
        width: Get.width,
        height: Get.height - 220.h,
        color: Colors.white54,
        child: Text('表层'),
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return banner(context);
  }
}
